package com.yaozheng.vocationaltraining.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.yaozheng.vocationaltraining.activity.BaseActivity;
import com.yaozheng.vocationaltraining.utils.BitmapLoader;
import com.yaozheng.vocationaltraining.utils.TypeUtils;
import com.yaozheng.vocationaltraining.view.exam.ItemLimitedChallengeView;
import com.yaozheng.vocationaltraining.view.exam.ItemLimitedChallengeView_;

import net.sf.json.JSONArray;

/**
 * Created by Administrator on 2017/9/3.
 */
public class LimitedChallengeAdapter extends BaseAdapter {
    private BaseActivity baseActivity;
    private JSONArray dataList;

    public LimitedChallengeAdapter(BaseActivity baseActivity, JSONArray dataList) {
        this.baseActivity = baseActivity;
        this.dataList = dataList;
    }


    public JSONArray getDataList() {
        return dataList;
    }

    public void setDataList(JSONArray dataList) {
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return TypeUtils.getJsonArraySize(dataList);
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ItemLimitedChallengeView itemLimitedChallengeView = null;
        if (convertView == null) {
            itemLimitedChallengeView = ItemLimitedChallengeView_.build(baseActivity);
        } else {
            itemLimitedChallengeView = (ItemLimitedChallengeView) convertView;
        }
        itemLimitedChallengeView.loadData(position, TypeUtils.getJsonObject(dataList, position));
        return itemLimitedChallengeView;
    }
}
